package org.dinner.order.model;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@NamedQueries({
	@NamedQuery(name="OrderItem.list", query="from OrderItem"),
	@NamedQuery(name="OrderItem.listByUserId", query="from OrderItem i where i.user.id=:userId")
})
@Table(name = "ORDER_ITEMS")
public class OrderItem {
	@Id
	@GeneratedValue
	private int id;
	@ManyToOne
	@JoinColumn(name = "user_id", nullable = false)
	private User user;
	private Date lastUpdate;
	@OneToMany(mappedBy = "item")
	private List<ItemDish> dishes = new ArrayList<ItemDish>();
	private double price;
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public Date getLastUpdate() {
		return lastUpdate;
	}
	public void setLastUpdate(Date lastUpdate) {
		this.lastUpdate = lastUpdate;
	}
	public double getPrice() {
		return price;
	}
	public void setPrice(double price) {
		this.price = price;
	}
	public List<ItemDish> getDishes() {
		return dishes;
	}
	public void setDishes(List<ItemDish> dishes) {
		this.dishes = dishes;
	}
	

}
